<?php
// +----------------------------------------------------------------------
// | 幕小铺
// +----------------------------------------------------------------------
// | 版权所有 2016~2020 幕小铺科技（上海）有限公司
// +----------------------------------------------------------------------
// | 2020/06/02
// +----------------------------------------------------------------------

namespace app\erp\model;

use think\Model;

/**
 * 储值管理
 * @package app\erp\model
 */
class UcMemberBalanceJournalLog extends Model
{
    // 设置当前模型对应的完整数据表名称
    protected $table = 'xm_uc_member_balance_journal_log';

    /**
     * 添加数据
     * @param uid 	                int             会员ID
     * @param ine 	                tinyint         类型(0:收入;1:支出)
     * @param price 		        decimal         金额
     * @param use_rule 		        int             使用规则
     * @param log_remark 		    decimal         备注
     * @param create_time 			int             创建时间
     * @author dou<51779987@qq.com>
     * @return array_out(code, message, (int)id)
     */
    public function addData($journal_id,$uid, $ine, $order_id, $song_price, $pay_type){
        $data['journal_id']                 = $journal_id;
        $data['uid']                        = $uid;
        $data['ine']                        = $ine;
        $data['order_id']                   = $order_id;
        $data['song_price']                 = $song_price;
        $data['pay_type']                   = $pay_type;
        $res = $this -> isUpdate(false) ->data($data, true) -> save();
        if($res){
            return array_out(200, 'success', $this->id);
        }else{
            return array_out(-1001, 'error');
        }
    }

    /**
     * 删除数据
     * @param int $id
     * @author dou<51779987@qq.com>
     * @return bool
     */
    public function deleteData($id){
        $res = self::destroy($id);
        if($res){
            return array_out(200, 'success');
        }else{
            return array_out(-1001, 'error');
        }
    }
}
